const state = {
  appName: '药店购药一键通',
	statusBarHeight: 0,
	screenHeight: 0,
	screenWidth: 0,
  menuButtonInfo: {}, // 微信小程序下胶囊信息
  errorType: ['toast'], // 全局表单的错误提示方式
}
const getters = {

}
const mutations = {
	setSystemInfo(state , systemInfo) {
		// console.log('systemInfo',systemInfo);
		for(let key in systemInfo) {
		   if(state.hasOwnProperty(key)){
			   state[key] = systemInfo[key]
		   }
		}
    // #ifdef MP-WEIXIN
    // 微信小程序获取胶囊
    let menuButtonInfo = uni.getMenuButtonBoundingClientRect()
    state.menuButtonInfo = menuButtonInfo
    // #endif
    // #ifndef MP-WEIXIN
    // 非微信小程序设置默认胶囊位置
    state.menuButtonInfo = {
      top: 10
    }
    // #endif
		// console.log('state',state);
	}
}
const actions = {
	loadSystemInfo({commit}) {
		uni.getSystemInfo({
			success: (res) => {
				// console.log(res);
				commit("setSystemInfo", res)
			}
		})
	}
}

export default {
	// namespaced: true,
	state,
	getters,
	actions,
	mutations
}
